<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <#include "/pubHeadStyleTree.html">
</head>
<body>
<form class="layui-form" action="" lay-filter="varItem" style="margin: 20px">
                <div class="layui-form-item">
                    <b>说明：</b>
                    <ul>
                        <li>该节点产生任务将下面选择方式发送通知给用户。</li>
                    </ul>

                </div>
    <div style="padding-top: 12px; float: left;margin-right: 10px">
        通知方式 ${bpmNodeSet.nodeName} :
    </div>
    <div class="layui-input-inline" style="width: 40%">
        <#list handlersMap?keys as key>
        <!--<input type="checkbox" name="informTypes" lay-filter="informType" value="${key}">-->
        <input type="checkbox" class="layui-input" lay-filter="informType"name="informTypes" lay-skin="primary" value="${key}"
        <#if key == bpmNodeSet.informType >
        checked="checked"
        </#if>
        />
        <span style="line-height: 44px;">
        ${handlersMap[key].title }
        </span>
        </#list>
    </div>
                <div class="layui-form-item">
                    <div style="display:none">
                        <br/><label><b>是否发信息给发起人 : </b></label>
                        <input type="checkbox" name="sendMsgToCreator" />
                        <#if bpmNodeSet.sendMsgToCreator == 1 ></#if>
                    </div>
                    <div>
                        <input type="hidden" name="informType"      value="" />
                        <input type="hidden" name="procDefId"       value="${procDefId}" />
                        <input type="hidden" name="nodeId"          value="${nodeId}" />
                        <input type="hidden" name="parentProcDefId" value="${parentProcDefId}" />
                    </div>
                </div>
                <div class="layui-btn-container" style="width:100%;position: absolute;bottom: 5px; left: 0px;text-align: center;">
                    <button class="layui-btn" lay-submit lay-filter="varForm">保存</button>
                    <button class="layui-btn layui-btn-danger" id="close">取消</button>
                </div>
</form>
<style>
    .layui-form-checkbox[lay-skin=primary]{
        padding-left: 0px;
    }
</style>

<script>
    layui.config({
        base: serverPath.systemPath + staticPath.systemPath //静态资源所在路径
    }).extend({
        index: 'index' //主入口模块
    }).use(['index','form','jquery','setter'], function(){
        var form = layui.form;
        var $ = layui.$;
        var setter = layui.setter;

        //监听提交
        form.on('submit(varForm)', function(data){
            var index = parent.layer.getFrameIndex(window.name);
            //赋值
            var informTypes = getTypes('informTypes');
            $('input[name="informType"]').val(informTypes );
            data.field.informType = informTypes;
            $.ajax({
                url: "${ctx}/workflow/actDefModel/saveInformType",
                type: "POST",
                dataType: 'json',
                data: data.field,
                success: function (result) {
                    //提示信息框
                    window.parent.layer.alert(result.msg);
                    // 关闭弹窗
                    parent.layer.close(index);
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    window.parent.layer.alert("保存失败！" + XMLHttpRequest.status);
                }
            })
            return false;
        });
        //取消按钮
        var index = parent.layer.getFrameIndex(window.name);
        $('#close').click(function () {
            parent.layer.close(index);
        })
        //获取被选中的键
        function getTypes(name) {
            var types = [] ;
            $("input[name='"+name+"']").each(function(){
                var me = $(this),
                    val = me.val(),
                    state = me.prop("checked");
                if(state)
                    types.push(val);
            });
            return types.join(',');
        }
    });
</script>
</body>
</html>